﻿using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace QQGarden
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        Index_BLL Index_BLL = new Index_BLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            Bind();
            
        }
        public void Bind()
        {

            RptProducts1.DataSource = Index_BLL.ProductInfo();
            RptProducts1.DataBind();
            RptProducts2.DataSource = Index_BLL.ProductInfo();
            RptProducts2.DataBind();
            RptProducts3.DataSource = Index_BLL.ProductInfo();
            RptProducts3.DataBind();
            Repeater1.DataSource = Index_BLL.ProductInfospecial();
            Repeater1.DataBind();
            Repeater2.DataSource = Index_BLL.ProductInfospecial2();
            Repeater2.DataBind();
            Repeater3.DataSource = Index_BLL.ProductInfospecial3();
            Repeater3.DataBind();
        }

        protected void LinkBtn1_Click(object sender, EventArgs e)
        {
            //通过ID获取单条信息
            LinkButton btn = (LinkButton)sender;  //强转
            int Products_ID =  Convert.ToInt32(btn.CommandArgument);  //获取LinkButton的CommandArgument
            Model.Index_Model index_Model = new Model.Index_Model();
            index_Model = Index_BLL.GetProductinfo(Products_ID);
            //获取信息后添加到购物车
            int i = Index_BLL.ShoppingCartinsert(index_Model);
            if(i>0)
            {
                Response.Write("<script>alert('已添加到购物车');</script>");
            }
                    


        }
    }
}